// pages/run/run.js
Page({
  data: {
    windowWidth:0,
    text:"",
    left:0,
    width:0//文字尺寸
  },
  onLoad:function(){
    this.getSystem();
    this.run();
  },
  run:function(){//滚动
    // console.log(this.data.left)
    let runDate = setInterval(()=>{
      if (this.data.left >= this.data.width - (this.data.width*2)){
        this.setData({
          left: this.data.left - 1
        })
        
      }else{
        clearInterval(runDate)
        this.setData({
          left: this.data.windowWidth
        })
        this.run()
      }
    },20)
  },
  getSystem:function(){//获取设备以及文案尺寸
    var that = this;//当前文字尺寸
    wx.createSelectorQuery().select('.every').boundingClientRect(function (res) {
      that.setData({
        width:res.width
      })
    }).exec();
    
    
    wx.getSystemInfo({//屏幕尺寸
      success: (res) => {
        this.setData({
          left: res.windowWidth,
          windowWidth: res.windowWidth
        })
        
      }
    })
  }
})